package com.sudo.api._res;

import com.sudo.api._admin.AdminBaseController;
import com.sudo.common.utils.JsonRes;
import com.sudo.common.utils.PagedGridResult;
import com.sudo.dao.res.entity.ResProvinceCity;
import com.sudo.dao.res.model.bo.ResProvinceCityBo;
import com.sudo.service.res.service.ResProvinceCityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(value = "省市区接口",tags = {"省市区相关的接口"})
@RestController
@RequestMapping("resProvinceCity")
public class ResProvinceCityController extends AdminBaseController {

    @Resource
    private ResProvinceCityService resProvinceCityService;

    @ApiOperation(value = "分页查询省市区",notes = "分页查询省市区",httpMethod = "POST")
    @PostMapping("/queryResProvinceCityByPage")
    public JsonRes queryResProvinceCityByPage(@RequestBody ResProvinceCityBo resProvinceCityBo) {
        PagedGridResult pagedGridResult = resProvinceCityService.queryResProvinceCityByPage(resProvinceCityBo);
        return JsonRes.ok(pagedGridResult);
    }

    @ApiOperation(value = "获取所有省份",notes = "获取所有省份",httpMethod = "GET")
    @GetMapping("/queryAddrByFatherCode")
    public JsonRes queryAllProvince(@RequestParam(value = "fatherCode",required = false) String fatherCode) {
        List<ResProvinceCity> resProvinceCityList = resProvinceCityService.queryAddrByFatherCode(fatherCode);
        return JsonRes.ok(resProvinceCityList);
    }
}
